package object;

public class Sheep {
    public int age;
    public int weight;

    public Sheep(int age, int weight){
        this.age = age;
        this.weight = weight;
    }

    public int hashCode() {
        System.out.println(super.hashCode());
        //暂时不考虑实现细节一律返回 零
        return 0;
    }

    public static void main(String[] args) {
        Sheep s = new Sheep(5,30);
        System.out.println(s.hashCode());
        //即使某个类重写了hashCode方法，任然可以通过 identityHashCode方法来获取原本由 Object 提供的 hashCode 所返回的 哈希码值
        System.out.println(System.identityHashCode(s));

        Sheep h = new Sheep(6,35);
        System.out.println(h.hashCode());
        System.out.println(System.identityHashCode(h));
    }
}
